Ext.namespace("Task.FeedBack.History");

Task.FeedBack.History.panel = function() {
	this.exeId;
	this.store = new Ext.data.Store({
		proxy: new Ext.data.HttpProxy({
			url: '../task/searchTaskFeedBack.form?timesnap=' + Date.parse(new Date())
		}),
		reader: new Ext.data.JsonReader({
			root: 'result',
			totalProperty: 'total',
			fields: ['USER_NAME', 'CONTENT', 'UPDATE_DATE','TASK_FEEDBACK_PERCENT','FROM_NAME','TO_NAME']
		}),listeners:{
			 beforeload :{    
	    	  	fn : function(thiz,options){
       	          Ext.apply(thiz.baseParams,
       	          { 
       	          	exeId:this.exeId
       	          });    
              },
              scope:this 
	    	}
		}
	});
	this.renderDays = function(value){
		var date = Date.parseDate(value.substring(0,10),"Y-m-d");
		var days = parseInt((date.getTime()-new Date().getTime())/(1000*60*60*24));
		if(days<0)
			return "<font color='red'>逾期"+(-days)+"天</font>";
		else
			return "<font >还剩"+days+"天</font>";
	};
	this.colModel = new Ext.grid.ColumnModel({
	    defaults: {
	        width: 100,
	        sortable: true,
	        align: 'center'
	    },
	    columns: [
			{header: 'TASK_ID', width: 50, hidden: true, dataIndex: 'TASK_ID'},
			{header: '反馈人', width: 50, dataIndex: 'FROM_NAME'},
			{header: '接受人', width: 50, dataIndex: 'TO_NAME'},
			{header: '反馈时间',width: 100, dataIndex: 'UPDATE_DATE'},
			{header: '反馈信息',width: 400, dataIndex: 'CONTENT'},
			{header: '完成百分比', hidden: true, dataIndex: 'TASK_FEEDBACK_PERCENT' ,renderer:function(value){return value+'%'}}
	    ]
	});
	
	this.gridPanel = new Ext.grid.GridPanel({
		region: 'center',
		cm:this.colModel,
		store:this.store,
		stripeRows: true, 
		sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
        loadMask: {msg: '加载中，请稍候...'},
        bbar:new Ext.PagingToolbar({
			 pageSize: 30,
	         store: this.store,
	         displayInfo: true,
	         displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	         emptyMsg: "没有记录..."
		}),
        viewConfig: { forceFit: true }
	})
	Task.FeedBack.History.panel.superclass.constructor.call(this, {
		title:'任务反馈历史信息',
		layout:'border',
		items:[this.gridPanel],
		listeners:{
			render:this.queryTask,
			activate:this.queryTask
		}
	});
};
Ext.extend(Task.FeedBack.History.panel, Ext.Panel, {
	initFeedBack:function(exeId){
		this.exeId = exeId;
	},
	queryTask :function(exeId){
		this.store.load({
			params:{
				start : 0,
				limit : 30,
				exeId:this.exeId
			}
		})
	}
});


